package cn.ift8.domain;

import java.io.Serializable;
import java.util.Set;

/**
 * Created by IFT8
 * on 2015/8/24.
 */
public class Customer implements Serializable {
    private Long cid;
    private String cname;
    private String password;
    //购物车
    private Set<Thing> buyCart;
    //订单
    private Set<ThingOrder> orders;

    public Customer() {
    }

    public Customer(String cname, String password, Set<Thing> buyCart, Set<ThingOrder> orders) {
        this.cname = cname;
        this.password = password;
        this.buyCart = buyCart;
        this.orders = orders;
    }

    public Long getCid() {
        return cid;
    }

    public void setCid(Long cid) {
        this.cid = cid;
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Set<Thing> getBuyCart() {
        return buyCart;
    }

    public void setBuyCart(Set<Thing> buyCart) {
        this.buyCart = buyCart;
    }

    public Set<ThingOrder> getOrders() {
        return orders;
    }

    public void setOrders(Set<ThingOrder> orders) {
        this.orders = orders;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.append("Customer{" +
                "cid=" + cid +
                ", cname='" + cname + '\'' +
                ", password='" + password + '\'' +
                ",buyCart='");

        for (Thing thing : buyCart) {
            stringBuilder.append(thing.toString());
            stringBuilder.append(',');
        }
        for (ThingOrder order : orders) {
            stringBuilder.append(
                    "ThingOrder{" +
                            "oid=" + order.getOid() +
                            ", state='" + order.getState() + '\'' +
                            ", date=" + order.getDate() +
                            ", orderThings=");
            Set<Thing> orderThings = order.getOrderThings();
            for (Thing orderThing : orderThings) {
                stringBuilder.append(orderThing.toString());
            }
        }

        return stringBuilder.toString();
    }
}
